package com.sparrow.task;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ScheduledTasks {
	
	@Autowired
	private JavaMailSender mailSender;
	
	 private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
	 @Scheduled(fixedRate = 5000)
	 public void reportCurrentTime() {
//		 SimpleMailMessage message = new SimpleMailMessage();
//		 message.setFrom("2093811632@qq.com");
//		 message.setTo("hujt@liveneo.com.cn");
//		 message.setSubject("主题：告警");
//		 message.setText("警告>警告>警告>警告>警告");
//		 mailSender.send(message);
		 System.out.println("现在时间：" + dateFormat.format(new Date()));
	 }
}
